package com.action.table;

import javax.swing.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;

public class JTableMainView {
    JTableView jtv = null;
    JFrame jf=null;
    JScrollPane jsp=null;
    public JTableMainView(String table,String[][] Result){
        int height=300;
        jtv=new JTableView(Result);
        jsp=jtv.getJScrollPane();
        jsp.setSize(500,300);
        jf=new JFrame(table);
        jf.add(jsp);
        if(Result.length==1)height=100; //单条结果
        jf.setSize(jtv.getSumAll(),height);
        Listener();
        jf.setVisible(true);
    }
    public void Listener(){
        WindowFocusListener windowFocusListener = new WindowFocusListener() {
            @Override
            public void windowGainedFocus(WindowEvent e) {
                System.out.println("haha");
            }

            @Override
            public void windowLostFocus(WindowEvent e) {
                System.out.println("ahah");
            }
        };
        this.jf.addWindowFocusListener(windowFocusListener);
    }
}
